<%@ page language="java" contentType="text/html; charset=BIG5"
	pageEncoding="BIG5"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=BIG5">
<title>datepicker demo</title>
<link rel="stylesheet" href="jquery-ui.css">
<script src="jquery-1.9.1.js"></script>
<script src="jquery-ui.js"></script>
</head>
<body>
	<%
		if (session.getAttribute("islogin") == null) {
			response.sendRedirect("login.html");
			return;
		}
	%>

	<form method="post">
		Please choose date and time!
		<div id="datepicker"></div>
		<script>
			$("#datepicker").datepicker();
			$("#datepicker").datepicker("option", "minDate", 2);
			$("#datepicker").datepicker("option", "maxDate", "+1m +2d");
			$("#datepicker").datepicker("option", "dateFormat", "yy-mm-dd");

			function redate() {
				//var currentDate = $("#datepicker").datepicker("getDate");
				var currentDate = $('#datepicker').datepicker({
					dateFormat : 'yy-mm-dd'
				}).val();
				//$("#datepicker").datepicker( "setDate", "10/12/2012" );
				var time1 = 0;
				var o = document.getElementsByName("time");
				for (i = 0; i < o.length; i++)
					if (o[i].checked) {
						var time1 = time1 + i + 1;
					}
				if (time1 == 0)
					alert("please choose time range!");
				else {

					document
							.write("<form action=createbooking2 method=post name=form1>");
					document
							.write("<input type=hidden name=date value='"
							+ currentDate + "'>");
					document
							.write("<input type=hidden name=time value='"
							+ time1 + "'>");
					document.write("</form>");
					document.form1.submit();
					/*window.location.replace("createbooking2?date=" + currentDate
							+ "&" + "time=" + time1);*/
				}
			}
		</script>

		<input name=time value=1 type=checkbox>9AM-12AM <input
			name=time value=2 type=checkbox>14PM-5PM <BR> <input
			type="button" value="next" onclick="redate()"><input type="button" value="main" onClick="location='main.jsp'">
	</form>
</body>
</html>